package mapeditor;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import mapeditor.itemselectpanel.ItemSelectionPanel;
import mapeditor.mappanel.DrawingArea;
import mapeditor.mappanel.old.ListViewScrollBar;
import mapeditor.treepanel.TreePanel;

public class MapEditorGUI extends JFrame
{
	public MapEditorGUI() {
		super( "MapEditor 0.001" );
		setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

		ListViewScrollBar listScrollBar = new ListViewScrollBar( );

		ItemSelectionPanel isp = new ItemSelectionPanel( 300 , listScrollBar );
		TreePanel tp = new TreePanel( );

		JScrollPane scrollPane2 = new JScrollPane( tp );
		JScrollPane scrollPane = new JScrollPane( isp );
		scrollPane.setVerticalScrollBar( listScrollBar );
		scrollPane.getVerticalScrollBar( ).setUnitIncrement( 200 );
		scrollPane2.getVerticalScrollBar( ).setUnitIncrement( 50 );

		JSplitPane splitPane = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT ,
				scrollPane2 , scrollPane );
		splitPane.setPreferredSize( new Dimension( 450 , dim.height ) );

		// Various sizing of the splitted panel
		splitPane.setOneTouchExpandable( false );
		splitPane.setDividerLocation( 200 );
		Dimension tpMinimumSize = new Dimension( 250 , 50 );
		Dimension scrollPaneMinimumSize = new Dimension( 200 , 50 );
		scrollPane2.setMinimumSize( tpMinimumSize );
		scrollPane2.setMaximumSize( tpMinimumSize );
		scrollPane.setMinimumSize( scrollPaneMinimumSize );
		scrollPane.setMaximumSize( scrollPaneMinimumSize );

		// add it all to the frame
		DrawingArea da = new DrawingArea( );
		add( da , BorderLayout.CENTER );
		add( splitPane , BorderLayout.WEST );
		setPreferredSize(dim);
		
		try {
			UIManager
					.setLookAndFeel( UIManager.getSystemLookAndFeelClassName( ) );
		} catch ( ClassNotFoundException e ) {
			e.printStackTrace( );
		} catch ( InstantiationException e ) {
			e.printStackTrace( );
		} catch ( IllegalAccessException e ) {
			e.printStackTrace( );
		} catch ( UnsupportedLookAndFeelException e ) {
			e.printStackTrace( );
		}
		SwingUtilities.updateComponentTreeUI( this );

		pack( );
		setResizable( false );
		setVisible( true );

	}

	public static void main( String[] args )
	{
		new MapEditorGUI( );
	}
}
